<!--# layout("/layout/weui.html",{}){  #-->
<style>
<!--
.author-header {
	width: 75px
}

.topic-summary {
	font-size: 8px;
	position: absolute;
	bottom: 0;
	right: 10px
}

.topic-item {
	min-height: 102px;
}
-->
</style>
<header class='demos-header'>
	<h1 class="demos-title">话题列表</h1>
</header>
<div class="weui_panel weui_panel_access">
	<div class="weui_panel_bd">
		<!--# for(topic in obj.data.topics.data){  #-->
		<a href="${base}/qa/topic/detail/${topic.id}" class="weui_media_box weui_media_appmsg">
			<div class="weui_media_hd">
				<img class="weui_media_appmsg_thumb" src="${topic.author.avatar_url}" alt="${topic.author.loginname}" title="${topic.author.loginname}">
			</div>
			<div class="weui_media_bd">
				<h4 class="weui_media_title">${topic.title}</h4>
				<p class="weui_media_desc topic-summary">发布于:${topic.create_at_forread} 分类: ${topic.tab} 点击数: ${topic.visit_count} 回复数:${topic.reply_count}</p>
			</div>
		</a>
		<!--# }  #-->
	</div>
</div>
<div class="args">
	<input type="hidden" id="page" value="${obj.data.page!}"> <input type="hidden" id="limit" value="${obj.data.limit!}"> <input type="hidden" id="search"
		value="${obj.data.search!}"> <input type="hidden" id="tab" value="${obj.data.tab!}"> <input type="hidden" id="tag" value="${obj.data.tag!}">
</div>

<script>
	var loading = false;
	$(document.body).infinite().on("infinite", function() {
		if (loading) {
			$.showLoading();
			return;
		}
		loading = true;
		$.showLoading();
		$.post('${base!}/qa/topic/json', {
			page : parseInt($('#page').val()) + 1,
			limit : $('#limit').val(),
			search : $('#search').val(),
			tab : $('#tab').val(),
			tag : $('#tag').val()
		}, function(result) {
			loading = false;
			$.hideLoading();
			var panel = $('.weui_panel_bd');
			if(result.operationState == 'SUCCESS'){
				$('#page').val(result.data.page);
				$(result.data.topics.data).each(function(i,item){
					panel.append('<a href="${base!}/qa/topic/detail/'+item.id+'" class="weui_media_box weui_media_appmsg">\
			<div class="weui_media_hd">\
				<img class="weui_media_appmsg_thumb" src="'+item.author.avatar_url+'" alt="'+item.author.loginname+'" title="'+item.author.loginname+'">\
			</div>\
			<div class="weui_media_bd">\
				<h4 class="weui_media_title">'+item.title +'</h4>\
				<p class="weui_media_desc topic-summary">发布于:'+item.create_at_forread+' 分类:'+item.tab+' 点击数:'+item.visit_count+'  回复数:'+item.reply_count+'</p>\
			</div></a>');
				});			
			}
		}, 'json')
	});
</script>
<!--# } #-->